//
//  HMEmjoCollectionView.swift
//  GuoGuo
//
//  Created by 艾小新 on 16/8/16.
//  Copyright © 2016年 xiaoxin. All rights reserved.
//

import UIKit

class HMEmjoCollectionView: UICollectionView {

   
    
    override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) {
        super.init(frame: frame, collectionViewLayout: layout)
        
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupUI() {
        
        backgroundColor = UIColor.whiteColor()
        
        // 隐藏滚动条
        self.showsHorizontalScrollIndicator = false
        // 分页
        self.pagingEnabled = true
        // 外部黑乎乎的
        self.bounces = false
    }
    
    // 设置itemSize等值
    override func layoutSubviews() {
        
        
        // 拿到布局
        let layout = self.collectionViewLayout as! UICollectionViewFlowLayout
        
        // 设置size
        layout.itemSize = CGSize(width: self.bounds.width, height: self.bounds.height)
        
        // 设置间距
        layout.minimumLineSpacing = 0
        layout.minimumInteritemSpacing = 0
        
        // 设置水平滚
        layout.scrollDirection = .Horizontal
        
        // 先设置，再调用，会执行数据源方法
        super.layoutSubviews()
    }

}
